package com.yh.intercept;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.yh.controller.NiuAction;
import lombok.Data;

import java.util.Date;

@Data
public class NiuIterceptor extends AbstractInterceptor {
    private int sleep;
    @Override
    public String intercept(ActionInvocation act) throws Exception {
        System.out.println("执行前:"+new Date().toLocaleString());
        NiuAction action = (NiuAction) act.getAction();
        action.setSleep(sleep);
       String result = act.invoke();
        System.out.println("执行后:"+new Date().toLocaleString());
        return result;
    }
}
